function show_add_banner()
{
    $('#add-banner').dialog({
        modal: true,
        width: 550,
        height: 510,
        buttons: {'Сохранить' : function() {$('#add-banner form').submit();}, 'Отмена' : function() {$(this).dialog('close');}}
    });
}

function show_edit_banner(banner_id)
{
    $.post('/ajax/banners/get_banner', {banner_id: banner_id},
        function(data) {
            $('#edit-banner').find('input[name = name]').val(data.banner.name);
            $('#edit-banner').find('input[name = key]').val(data.banner.key);
            $('#edit-banner').find('textarea[name = text]').val(data.banner.text);
            $('#edit-banner').find('input[name = banner_id]').val(data.banner.banner_id);
            
            $('#edit-banner').dialog({
                modal: true,
                width: 550,
                height: 510,
                buttons: {'Сохранить' : function() {$('#edit-banner form').submit();}, 'Отмена' : function() {$(this).dialog('close');}}
            });  
    }, 'json');
}

function check_banner_form(form)
{
    var name  = $(form).find('input[name = name]').val();
    var key   = $(form).find('input[name = key]').val();
    var text  = $(form).find('textarea[name = text]').val();
    
    if(name && key && text)
        return true;
    
    $('#banner-form-error').dialog('open');
    
    return false;
}